#define cardAddOrEdit(modelName,url)
<div class="card-header">
    <header>
        <h2 class="card-title">#(modelName)</h2>
        <div class="progress">
            <div class="progress-bar bg-success" role="progressbar" style="width: 100%" aria-valuenow="100"
                 aria-valuemin="0"
                 aria-valuemax="100"></div>
        </div>
    </header>
</div>
<div class="card-block">
    <form class="form-horizontal clearfix margin-top-30" id="jmisForm" action="/admin/#(url)/saveOrUpdate"
          method="post">
        <div class="row">
            #@cardCol()
            <div class="col-sm-12">
                <div class="form-group">
                    <div class="col-sm-offset-4 col-sm-8">
                        <button type="submit" class="btn btn-success btn--icon-text waves-effect"><i
                                class="zmdi zmdi-check"></i> 提交
                        </button>
                        #permission("/admin/#(url)")
                        <button type="button" id="backList" class="btn btn-danger btn--icon-text waves-effect"><i
                                class="zmdi zmdi-arrow-back"></i> 返回列表
                        </button>
                        #end
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<script src="/assets/app/table.js?v=#(resource_version)"></script>
<script type="text/javascript">
    ready('#(url)', #(p), #(s), #(model.id ??));
    $("#backList").click(function () {
        $.pjax({url: "/admin/#(url)?p=#(p)&s=#(s)", container: '#pjax-container'});
    })
</script>
#end
#define zTree(title,name,url)
<link rel="stylesheet" href="/assets/ztree/zTreeStyle.css?v=#(resource_version)">
<script type="text/javascript" src="/assets/ztree/jquery.ztree.core.js?v=#(resource_version)"></script>
<script type="text/javascript" src="/assets/ztree/jquery.ztree.excheck.js?v=#(resource_version)"></script>
<script type="text/javascript" src="/assets/ztree/jquery.ztree.exedit.js?v=#(resource_version)"></script>
<div class="form-group ztreeUlBackground left">
    <label>#(title??)</label>
    <input type="text" class="form-control" placeholder="请选择#(title??)..." id="InputBox" onfocus="blur()"
           onclick="showMenu();" autocomplete="off" name="#(name??)">
    <input type="hidden" name="#(name??)" id="InputBoxValue" value="0"/>
    <i class="form-group__bar"></i>
</div>
<div class="form-group" id="menuContent" style="display:none; position: absolute;background: wheat;z-index: 9999">
    <ul id="treeUl" class="ztree" style="margin-top:0; width:800px; height: 100%;">
    </ul>
</div>
<script type="text/javascript">
    $(function () {
        $.post("#(url??)", function (result) {
            var kinit = $.fn.zTree.init($("#treeUl"), setting, result);
            //展开所有节点
            kinit.expandAll(true);
        })
    })

    var setting = {
        check: {
            enable: true,
            chkStyle: "radio",
            radioType: "all"
        },
        view: {
            dblClickExpand: false,
            addHoverDom: addHoverDom,
            removeHoverDom: removeHoverDom,
            selectedMulti: false
        },
        data: {
            simpleData: {
                enable: true
            }
        },
        callback: {
            onClick: onClick,
            onCheck: onCheck,
            beforeDrag: beforeDrag,
            beforeEditName: beforeEditName,
            beforeRemove: beforeRemove,
            beforeRename: beforeRename,
            onRemove: onRemove,
            onRename: onRename
        }, edit: {
            enable: true,
            editNameSelectAll: true,
            showRemoveBtn: showRemoveBtn,
            showRenameBtn: showRenameBtn
        }
    };




    function onClick(e, treeId, treeNode) {
        var zTree = $.fn.zTree.getZTreeObj("treeUl");
        zTree.checkNode(treeNode, !treeNode.checked, null, true);
        return false;
    }

    function onCheck(e, treeId, treeNode) {
        var zTree = $.fn.zTree.getZTreeObj("treeUl"),
            nodes = zTree.getCheckedNodes(true),
            v = "";
        id = "";
        for (var i = 0, l = nodes.length; i < l; i++) {
            v += nodes[i].name + ",";
            id += nodes[i].id + ",";

        }
        if (v.length > 0) v = v.substring(0, v.length - 1);
        if (id.length > 0) id = id.substring(0, id.length - 1);
        var cityObj = $("#InputBox");
        cityObj.attr("value", v);
        $("#InputBoxValue").attr("value", id);
        $("#InputBox").removeAttr("name");
    }

    function showMenu() {
        $("#menuContent").slideDown("fast");
        $("body").bind("mousedown", onBodyDown);
    }

    function hideMenu() {
        $("#menuContent").fadeOut("fast");
        $("body").unbind("mousedown", onBodyDown);
    }

    function onBodyDown(event) {
        if (!(event.target.id == "menuBtn" || event.target.id == "InputBox" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length > 0)) {
            hideMenu();
        }
    }

    var log, className = "dark";

    function beforeDrag(treeId, treeNodes) {
        return false;
    }

    function beforeEditName(treeId, treeNode) {
        className = (className === "dark" ? "" : "dark");
        var zTree = $.fn.zTree.getZTreeObj("treeUl");
        zTree.selectNode(treeNode);
        zTree.editName(treeNode);
        return false;
    }

    function beforeRemove(treeId, treeNode) {
        className = (className === "dark" ? "" : "dark");
        var zTree = $.fn.zTree.getZTreeObj("treeUl");
        zTree.selectNode(treeNode);
        return confirm("确认删除 节点 -- " + treeNode.name + " 吗？");
    }

    function onRemove(e, treeId, treeNode) {
    }

    function beforeRename(treeId, treeNode, newName, isCancel) {
        className = (className === "dark" ? "" : "dark");
        if (newName.length == 0) {
            setTimeout(function () {
                var zTree = $.fn.zTree.getZTreeObj("treeUl");
                zTree.cancelEditName();
                alert("节点名称不能为空.");
            }, 0);
            return false;
        }
        return true;
    }

    function onRename(e, treeId, treeNode, isCancel) {
    }

    function showRemoveBtn(treeId, treeNode) {
        return !treeNode.isFirstNode;
    }

    function showRenameBtn(treeId, treeNode) {
        return !treeNode.isLastNode;
    }

    function showLog(str) {
        if (!log) log = $("#log");
        log.append("<li class='" + className + "'>" + str + "</li>");
        if (log.children("li").length > 8) {
            log.get(0).removeChild(log.children("li")[0]);
        }
    }

    var newCount = 1;

    function addHoverDom(treeId, treeNode) {
        var sObj = $("#" + treeNode.tId + "_span");
        if (treeNode.editNameFlag || $("#addBtn_" + treeNode.tId).length > 0) return;
        var addStr = "<span class='button add' id='addBtn_" + treeNode.tId
            + "' title='add node' onfocus='this.blur();'></span>";
        sObj.after(addStr);
        var btn = $("#addBtn_" + treeNode.tId);
        if (btn) btn.bind("click", function () {
            var zTree = $.fn.zTree.getZTreeObj("treeUl");
            zTree.addNodes(treeNode, {id: (100 + newCount), pId: treeNode.id, name: "new node" + (newCount++)});
            return false;
        });
    };

    function removeHoverDom(treeId, treeNode) {
        $("#addBtn_" + treeNode.tId).unbind().remove();
    };

</script>
#end

